<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>API-all</title>
</head>
<body>
  <script>
    // Promise.all() 方法：传入一个 Promise 对象数组
    const p1 = Promise.resolve('p1 resolve');
    const p2 = Promise.resolve('p2 resolve');
    const p3 = Promise.resolve('p3 resolve');
    const p4 = Promise.reject('p4 reject');
    const p5 = Promise.reject('p5 reject');
    

    // 传入的都是成功的 Promise 对象
    const all_resolve = Promise.all([p1, p2, p3]);
    console.log(all_resolve); // 返回的 Promise 对象状态为 fullfilled，结果为 ['p1 resolve', 'p2 resolve', 'p3 resolve']

    // 传入的有失败的 Promise 对象
    const some_reject = Promise.all([p1, p5, p4]);
    console.log(some_reject); // 返回的 Promise 对象状态为 rejected，结果为第一个失败的返回值，上述返回 p5 的失败值
  </script>
</body>
</html>